/*
 * PopupCanvassVoteMsg.cpp
 *
 *  Created on: Jul 17, 2012
 *      Author: guillou
 */

#include "PopupCanvassVoteMsg.hpp"

using namespace std;
using namespace Popup;

CanvassVoteMsg::CanvassVoteMsg(const Message *p_message)
: AbstractMessage(POPUP_MSG_TYPE_CANVASS_VOTE)
{
  AbstractMessage::deserialize(p_message);
}

bool CanvassVoteMsg::onSend()
{
  bool _rc = payloadAddLongLong(CANVASS_ID, canvassID);

  if (_rc) {
    _rc = payloadAddLong(TARGETS, targets);
  }
  if (_rc) {
    payloadAddLong(VOTER, voterID);
  }
  if (_rc) {
    payloadAddShort(CHOICES, choices);
  }

  return _rc;
}

bool CanvassVoteMsg::onReceive()
{
  bool _rc = payloadGetLongLong(CANVASS_ID, canvassID);

  if (_rc) {
    _rc = payloadGetLong(TARGETS, targets);
  }
  if (_rc) {
    payloadGetLong(VOTER, voterID);
  }
  if (_rc) {
    payloadGetShort(CHOICES, choices);
  }

  return _rc;
}
